package com.ruoyi.http.controller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.data.DataUtils;
import com.ruoyi.data.MD5;
import com.ruoyi.http.domain.Http;
import com.ruoyi.http.domain.WeChat00300T;
import com.ruoyi.http.domain.WeChat00700T;
import com.ruoyi.http.domain.WeChat01400T;
import com.ruoyi.http.service.IWeChatTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/http/weChat01400")
public class WeChat01400 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;
    @GetMapping("/weChat")
    public AjaxResult http(WeChat01400T weChat01400T) throws Exception {
        WeChat01400T weChat = new WeChat01400T();
        weChat = weChatTService.getCostInfoByHouseId(weChat01400T);
        if (weChat.getUsername()!=null){
            weChat.setUsername(MD5.encrypt(weChat.getUsername()));
        }
        if(DataUtils.divideMoney(weChat.getBalance(),weChat.getBudgetmoney())>0.3) {
            weChat.setCostmoney(0d);
        } else {
            weChat.setCostmoney(DataUtils.subMoney(weChat.getBudgetmoney(), weChat.getBalance()));
        }
        return AjaxResult.success(weChat);
    }
}